package com.weishu.core.service.impl;

import com.weishu.common.core.web.domain.AjaxResult;
import com.weishu.core.entity.BusinessEntity;
import com.weishu.core.entity.TbBusiness;
import com.weishu.core.mapper.TbBusinessMapper;
import com.weishu.core.service.ITbBusinessService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 商户表 服务实现类
 * </p>
 *
 * @author zgx
 * @since 2021-10-19
 */
@Service
public class TbBusinessServiceImpl extends ServiceImpl<TbBusinessMapper, BusinessEntity> implements ITbBusinessService {

    @Override
    public List<BusinessEntity> listAll() {
        return this.getBaseMapper().listAll();
    }

    @Override
    public AjaxResult updateStatusById(BusinessEntity businessEntity) {
        try {
            //审核通过
            if (businessEntity.getStatus()==1){
                this.getBaseMapper().updateStatusById(businessEntity.getId());
            }else{
                //审核不通过
                this.getBaseMapper().updateStatusById2(businessEntity.getId());
            }
            return AjaxResult.success("审核成功！");
        }catch (Exception e){
            return AjaxResult.error(500,"审核失败！");
        }
    }

    @Override
    public boolean add(BusinessEntity businessEntity) {
        System.out.println(businessEntity);
        try {
            this.getBaseMapper().add(businessEntity);
            return true;
        }catch (Exception e){
            e.printStackTrace();
            return false;
        }

    }
}
